package com.yby.dome2;

public class Rectangle {
    private double length;
    private double width;
    //无参构造
    public Rectangle(){
    }
    //有参构造,适合保存不适合修改
    public Rectangle(double width, double length){
        this.width = width;
        this.length = length;
    }
    public void setLength(double length){
        this.length = length;
    }
    public void setWidth(double width){
        this.width = width;
    }
    public double getLength(){
        return length;
    }
    public double getWidth(){
        return width;
    }
    //求面积
    public double getArea(){
      return length*width;
    }
    //求周长
    public double getPer(){
        return 2*(length+width);
    }
    //在控制台输出长、宽、面积、周长
    public void showAll(){
        System.out.println("长为："+length);
        System.out.println("宽为："+width);
        System.out.println("面积："+getArea());
        System.out.println("周长："+getPer());
    }
}
